package main

import (
	"fmt"
)

func main() {
	sum := twoSum([]int{1, 2, 3}, 4)
	fmt.Println(sum)
}

func twoSum(nums []int, target int) []int {
	var mp = make(map[int]int, len(nums))
	for i := 0; i < len(nums); i++ {
		num := nums[i]
		index, exist := mp[target-num]
		if exist {
			return []int{i, index}
		} else {
			mp[num] = i
		}
	}
	return nil
}
